package com.kizuki.reflect;

import org.junit.Test;
import java.util.Arrays;

public class TestAnnotation {

    @Test
    public void testInherited() {
        Class<Son> sonClass = Son.class;
        MyAnnotation annotation = sonClass.getAnnotation(MyAnnotation.class);
        System.out.println(Arrays.toString(annotation.likes())); // [game, music]
        System.out.println(annotation.annotationType()); // interface com.kizuki.reflect.MyAnnotation
        System.out.println(annotation.getClass()); // class com.sun.proxy.$Proxy5
    }

    @Test
    public void test() {
        Class<Son> cl = Son.class;
        System.out.println(cl.isAnnotationPresent(SuppressWarnings.class)); // false Inherited会覆盖子类的注解?
        System.out.println(cl.isAnnotationPresent(MyAnnotation.class)); // true
    }
}


@MyAnnotation(likes = {"game", "music"})
class Father {

}

@SuppressWarnings("all")
class Son extends Father {

}




